<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link href="../css/mui.min.css" rel="stylesheet" />
    <link href="../phoneCss/commons.css?r=1" rel="stylesheet" />
    <link href="../phoneCss/login.css" rel="stylesheet" />
</head>
<body>
<header class="mui-bar mui-bar-nav">
    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
    <h1 class="mui-title">登录</h1>
</header>
<div class="mui-content">
    <ul class="bund-title mui-clearfix">
        <li class="bund-act" id="hasCount">绑定已有账号</li>
        <li id="noCount">账号授权</li>
    </ul>
    <div class="login2-login-box mui-clearfix">
        <div class="login2-user" id="phoneBox">
            <input id="phone" type="text" placeholder="请输入您的手机号">
        </div>
        <div class="login2-password" id="passloginbox">
            <input class="password" type="password" placeholder="请输入您的密码">
        </div>
        <div class="login2-user" style="display: none;" id="codeBox">
            <input id="code" type="text" placeholder="请输入验证码">
            <a class="code-button">获取验证码</a>
        </div>
        <div class="login-button" id="login-button">绑定并登录</div>
        <div class="login-button" id="login-button2" style="display: none">授权登录并绑定</div>
    </div>
</div>


<script src="../js/mui.min.js"></script>
<script src="../js/jquery-1.10.1.min.js"></script>
<script>  document.write("<s"+"cript type='text/javascript' src='../js/common.js?"+Math.random()+"'></scr"+"ipt>"); </script>
<script src="../js/md5.js"></script>
<script type="text/javascript">
    var code = GetQueryString('code');
    var accessToken = '';
    var openId = '';
    var Astate = '';
    if(code==""||code==undefined||code==null){}else{
        /*alert('code');
        window.location.href="https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxcae7693294154eb4&secret=1bad93acbef98bcec9c564badb4c2e32&code="+code+"&grant_type=authorization_code"*/
        $.ajax({
            url:'/OAuth/OAuthIsRegist2.json',
            dataType:'json',
            data:{
                code:code,
                state:GetQueryString('state'),
                companyCode:getItem('companyCode'),
            },
            type:'post',
            success:function (data) {
                if(data.code==0){
                    mui.toast(data.msg);
                }
                if(data.code==1){
                    if(data.datas.isOAuth==1){
                        //绑定过手机号，登录成功跳转到首页
                        setItem('token',data.datas.token);
                        setItem('phone',data.datas.userPhone);
                        setItem('userId',data.datas.userId);
                        window.location.href="index.html?companyCode="+getItem('companyCode');
                    }else if(data.datas.isOAuth==0){
                        //没有绑定手机号，登录失败跳转到绑定页面
                        accessToken = data.datas.accessToken;
                        openId = data.datas.openId;
                        Astate = data.datas.state;
                        window.location.href="bundCount.html?accessToken="+accessToken+'&openId='+openId+'&state='+Astate;
                    }

                }
            }
        })
    }
</script>
</body>
</html>
